//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.msg;

import java.awt.*;
import javax.swing.*;

public class MsgGUI extends JInternalFrame {

    public MsgGUI() {
        jContentPane = null;
        jScrollPane = null;
        jTextArea = null;
        initialize();
    }

    private void initialize() {
        setFrameIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/arrowRight18x18.png")));
        setTitle("Message");
        setSize(300, 200);
        setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getJScrollPane(), "Center");
        }
        return jContentPane;
    }

    private JScrollPane getJScrollPane() {
        if (jScrollPane == null) {
            jScrollPane = new JScrollPane();
            jScrollPane.setViewportView(getJTextArea());
            jScrollPane.setHorizontalScrollBarPolicy(31);
        }
        return jScrollPane;
    }

    private JTextArea getJTextArea() {
        if (jTextArea == null) {
            jTextArea = new JTextArea();
            jTextArea.setLineWrap(true);
            jTextArea.setWrapStyleWord(true);
            jTextArea.setBackground(new Color(255, 255, 102));
            jTextArea.setForeground(new Color(0, 0, 153));
            jTextArea.setFont(new Font("Arial", 1, 18));
            jTextArea.setEditable(false);
            String s = "<html>Cliquer sur la croix<br>en haut \340 droite pour<br>fermer cette fen\352tre !</html>";
            jTextArea.setToolTipText(s);
        }
        return jTextArea;
    }

    public String getMsg() {
        return getJTextArea().getText();
    }

    public void setMsg(String txt) {
        getJTextArea().setText(txt);
    }
    private JPanel jContentPane;
    private JScrollPane jScrollPane;
    private JTextArea jTextArea;
}
